home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH24 / SGDITEST.ASM < prev   
Encoding:
Assembly Source File  |  1994-07-28  |  4.0 KB  |  246 lines

  1.         .xlist
  2.         include     stdlib.a
  3.         includelib    stdlib.lib
  4.         .list
  5.  
  6.  
  7. cseg        segment    para public 'code'
  8.         assume    cs:cseg, ds:nothing
  9.  
  10. MinVal0        word    ?
  11. MinVal1        word    ?
  12. MaxVal0        word    ?
  13. MaxVal1        word    ?
  14.  
  15.  
  16.  
  17. Wait4Button    proc    near
  18.         push    ax
  19.         push    dx
  20.         push    cx
  21.  
  22. W4BLp:        mov    ah, 84h
  23.         mov    dx, 900h
  24.         int    15h
  25.         cmp    ax, 0
  26.         je    W4BLp
  27.  
  28.         xor    cx, cx
  29. Delay:        loop    Delay
  30.  
  31. W4nBLp:        mov    ah, 84h
  32.         mov    dx, 900h
  33.         int    15h
  34.         cmp    ax, 0
  35.         jne    W4nBLp
  36.  
  37. Delay2:        loop    Delay2
  38.  
  39.         pop    cx
  40.         pop    dx
  41.         pop    ax
  42.         ret
  43. Wait4Button    endp
  44.  
  45. Main        proc
  46.  
  47.         print
  48.         byte    "SGDI Test Program.",cr,lf
  49.         byte    "Written by Randall Hyde",cr,lf,lf
  50.         byte    "Press any key to continue",cr,lf,0
  51.  
  52.         getc
  53.  
  54.         mov    ah, 84h
  55.         mov    dh, 4            ;Test presence call.
  56.         int    15h
  57.         cmp    ax, 0            ;See if there
  58.         je    MainLoop0
  59.         print
  60.         byte    "No SGDI driver present in memory.",cr,lf,0
  61.         jmp    Quit
  62.  
  63. MainLoop0:    print
  64.         byte    "BIOS: ",0
  65.  
  66. ; Okay, read the switches and raw pot values using the BIOS compatible calls.
  67.  
  68.         mov    ah, 84h
  69.         mov    dx, 0            ;BIOS compat. read switches.
  70.         int    15h
  71.         puth                ;Output switch values.
  72.         mov    al, ' '
  73.         putc
  74.  
  75.         mov    ah, 84h            ;BIOS compat. read pots.
  76.         mov    dx, 1
  77.         int    15h
  78.         putw
  79.         mov    al, ' '
  80.         putc
  81.         mov    ax, bx
  82.         putw
  83.         mov    al, ' '
  84.         putc
  85.         mov    ax, cx
  86.         putw
  87.         mov    al, ' '
  88.         putc
  89.         mov    ax, dx
  90.         putw
  91.  
  92.         putcr
  93.         mov    ah, 1        ;Repeat until key press.
  94.         int    16h
  95.         je    MainLoop0
  96.         getc
  97.  
  98.  
  99. ; Read the minimum and maximum values for each pot from the user so we
  100. ; can calibrate the pots.
  101.  
  102.         print
  103.         byte    cr,lf,lf,lf
  104.         byte    "Move joystick to upper left corner and press "
  105.         byte    "any button.",cr,lf,0
  106.  
  107.         call    Wait4Button
  108.         mov    ah, 84h
  109.         mov    dx, 1        ;Read Raw Values
  110.         int    15h
  111.         mov    MinVal0, ax
  112.         mov    MinVal1, bx
  113.  
  114.         print
  115.         byte    cr,lf
  116.         byte    "Move the joystick to the lower right corner "
  117.         byte    "and press any button",cr,lf,0
  118.  
  119.         call    Wait4Button
  120.         mov    ah, 84h
  121.         mov    dx, 1        ;Read Raw Values
  122.         int    15h
  123.         mov    MaxVal0, ax
  124.         mov    MaxVal1, bx
  125.  
  126. ; Calibrate the pots.
  127.  
  128.         mov    ax, MinVal0    ;Will be eight bits or less.
  129.         mov    bx, MaxVal0
  130.         mov    cx, bx        ;Compute centered value as the
  131.         add    cx, ax         ; average of these two (this is
  132.         shr    cx, 1        ; dangerous, but usually works!)
  133.         mov    ah, 84h
  134.         mov    dx, 300h    ;Calibrate pot 0
  135.         int    15h
  136.  
  137.         mov    ax, MinVal1    ;Will be eight bits or less.
  138.         mov    bx, MaxVal1
  139.         mov    cx, bx        ;Compute centered value as the
  140.         add    cx, ax        ; average of these two (this is
  141.         shr    cx, 1        ; dangerous, but usually works!)
  142.         mov    ah, 84h
  143.         mov    dx, 301h    ;Calibrate pot 1
  144.         int    15h
  145.  
  146. MainLoop1:    print
  147.         byte    "ReadSw: ",0
  148.  
  149. ; Okay, read the switches and raw pot values using the BIOS compatible calls.
  150.  
  151.         mov    ah, 84h
  152.         mov    dx, 800h        ;Read switch zero.
  153.         int    15h
  154.         or    al, '0'
  155.         putc
  156.  
  157.         mov    ah, 84h
  158.         mov    dx, 801h        ;Read switch one.
  159.         int    15h
  160.         or    al, '0'
  161.         putc
  162.  
  163.         mov    ah, 84h
  164.         mov    dx, 802h        ;Read switch two.
  165.         int    15h
  166.         or    al, '0'
  167.         putc
  168.  
  169.         mov    ah, 84h
  170.         mov    dx, 803h        ;Read switch three.
  171.         int    15h
  172.         or    al, '0'
  173.         putc
  174.  
  175.         mov    ah, 84h
  176.         mov    dx, 804h        ;Read switch four
  177.         int    15h
  178.         or    al, '0'
  179.         putc
  180.  
  181.         mov    ah, 84h
  182.         mov    dx, 805h        ;Read switch five.
  183.         int    15h
  184.         or    al, '0'
  185.         putc
  186.  
  187.         mov    ah, 84h
  188.         mov    dx, 806h        ;Read switch six.
  189.         int    15h
  190.         or    al, '0'
  191.         putc
  192.  
  193.         mov    ah, 84h
  194.         mov    dx, 807h        ;Read switch seven.
  195.         int    15h            ;We won't bother with
  196.         or    al, '0'            ; any more switches.
  197.         putc
  198.         mov    al, ' '
  199.         putc
  200.  
  201.         mov    ah, 84h
  202.         mov    dh, 9            ;Read all 16 switches.
  203.         int    15h
  204.         putw
  205.  
  206.         print
  207.         byte    "  Pots: ",0
  208.         mov    ax, 8403h        ;Read joystick pots.
  209.         mov    dx, 200h        ;Read four pots.
  210.         int    15h
  211.         puth
  212.         mov    al, ' '
  213.         putc
  214.         mov    al, ah
  215.         puth
  216.         mov    al, ' '
  217.         putc
  218.  
  219.         mov    ah, 84h
  220.         mov    dx, 503h        ;Raw read, pot 3.
  221.         int    15h
  222.         putw
  223.  
  224.         putcr
  225.         mov    ah, 1        ;Repeat until key press.
  226.         int    16h
  227.         je    MainLoop1
  228.         getc
  229.  
  230.  
  231.  
  232.  
  233. Quit:        ExitPgm            ;DOS macro to quit program.
  234. Main        endp
  235.  
  236. cseg        ends
  237.  
  238. sseg        segment    para stack 'stack'
  239. stk        byte    1024 dup ("stack   ")
  240. sseg        ends
  241.  
  242. zzzzzzseg    segment    para public 'zzzzzz'
  243. LastBytes    byte    16 dup (?)
  244. zzzzzzseg    ends
  245.         end    Main
  246.